﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;

namespace Inaction.Linq.Clause
{
    class UnaryClause : WhereClause
    {
        object value;
        public UnaryClause(LinqRoot root, UnaryExpression e)
            : base(root, e)
        {
            Type = e.Operand.Type;
            if (e.Operand.Type == typeof(Boolean))
            {
                var express = e.Operand as System.Linq.Expressions.ConstantExpression;
                if (express != null)
                {
                    Right = new BooleanClause(root, (bool)express.Value);
                }
                else
                    Right = new BooleanClause(root, true);
            }
            else
            {
                Right = LinqParse.Parse(e.Operand, root);
            }
        }

        public override string GetClauseSql()
        {
            return base.GetClauseSql();
        }
    }
}
